<?php

namespace app\python\controller;

use app\common\RootController;
use app\python\service\TaskService;

class Task extends RootController
{
    /**
     * 采集任务
     * @param TaskService $service
     * @return \think\response\Json
     */
    public function tabulation(TaskService $service)
    {
        return $this->success($service->lists());
    }

    /**
     * 保存文章内容
     * @param TaskService $service
     * @return \think\response\Json
     * @throws \app\common\RootException
     */
    public function keepContent(TaskService $service)
    {
        return $this->success($service->addContent($this->request->param()));
    }

    /**
     * 查询已经采集的文章
     * @param TaskService $service
     * @return \think\response\Json
     */
    public function being(TaskService $service)
    {
        return $this->success($service->being($this->request->param()));
    }

    /**
     * 生成缩略图
     * @param TaskService $service
     * @return \think\response\Json
     */
    public function thumb(TaskService $service)
    {
        return $this->success($service->generateThumb());
    }

    /**
     * 删除文章
     * @param TaskService $service
     * @return \think\response\Json
     * @throws \app\common\RootException
     */
    public function del(TaskService $service)
    {
        return $this->success($service->del($this->request->param('id')));
    }
}